@extends('seller.layouts.app')

@section('panel_content')

    
    <!--新的-->
       <div class="indexcon">
        <div class="indexconL">
            <div class="indexconL1">
                <div class="person">
                    <div class="personmsg">
                     <!--<img src="{{ static_asset('assets/img/newimg/home/tx.png') }}" alt="" width="">-->
  @if (Auth::user()->shop->logo != null)
                 <img 
                                    src="{{ uploaded_asset(Auth::user()->avatar_original) }}"
                                    onerror="this.onerror=null;this.src='{{ static_asset('assets/img/avatar-place.png') }}';"
                                    style="object-fit: contain;    height: auto; max-width: 20%; width: 20%;"
                                >
                @else
                <!--<img class="" src="{{ uploaded_asset(get_setting('header_logo')) }}" class="brand-icon"-->
                <!--     alt="{{ get_setting('site_name') }}"-->
                <!--     style="object-fit: contain;    height: auto; max-width: 40%; width: 40%;"-->
                <!--     >-->
                <img class="" src="{{ static_asset('assets/img/avatar-place.png') }}" class="brand-icon"
                     alt="{{ get_setting('site_name') }}"
                     style="object-fit: contain;    height: auto; max-width: 20%; width: 20%;"
                     >
                @endif
              
                        <div class="personmsgR">
                            <h2 style="font-size:0.8rem">
                               {{Auth::user()->name}}
                            </h2>
                            <p>
                @if (Auth::user()->shop->rating >4 )
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                @endif
                                     @if (Auth::user()->shop->rating >3  && Auth::user()->shop->rating <=4)
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                @endif
                                @if (Auth::user()->shop->rating >2 && Auth::user()->shop->rating <=3)
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                @endif
                                @if (Auth::user()->shop->rating >1  && Auth::user()->shop->rating <=2)
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                @endif
                                @if (Auth::user()->shop->rating >0 && Auth::user()->shop->rating <=1)
                  <img src="{{ static_asset('assets/img/newimg/home/star1.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                @endif
                                                @if (Auth::user()->shop->rating ==0)
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                  <img src="{{ static_asset('assets/img/newimg/home/star2.png') }}" >
                @endif
                                <span>   {{ Auth::user()->shop->rating }}
</span>
                            </p>
                        </div>
                    </div>
                      <div class="">
        @if (addon_is_activated('seller_subscription'))
        <div class="">
            <div class="">
             
                @if (Auth::user()->shop->seller_package)
                     <div class="shopmsg">
                        <img src="{{ uploaded_asset(Auth::user()->shop->seller_package->logo) }}">
                        <div class="shopmsgR">
                            <div style="display:flex">
                                <h2 class="pc" style="font-size:14px">{{ \App\Models\SellerPackageTranslation::where('seller_package_id', Auth::user()->shop->seller_package->id)->where('lang',Session::get('locale', Config::get('app.locale')) )->value('name') }}</h2>
                             @if (Auth::user()->shop->verification_status == 1)
                                <h2 class="pc" style="font-size:14px">|{{translate('been_certification')}}</h2>
                                 @else
                                 <h2 class="pc" style="font-size:14px">|{{translate('None Certification')}}</h2>
                             @endif
                            </div>
                            <div >
                                 <h2 class="m" style="font-size:16px"><a href="{{ route('seller.seller_packages_list') }}">        
                                 {{ \App\Models\SellerPackageTranslation::where('seller_package_id', Auth::user()->shop->seller_package->id)->where('lang',Session::get('locale', Config::get('app.locale')) )->value('name') }}</a></h2>
                                @if (Auth::user()->shop->verification_status == 1)
                                <br/>
                            
                                <h2 class="m" style="font-size:14px">{{translate('been_certification')}}</h2>
                                 @else
                                 <h2 class="m" style="font-size:14px">{{translate('None Certification')}}</h2>
                                 
                             @endif
                            </div>
                            <p>
                               {{ translate('Product Upload Limit') }}:
                                {{ Auth::user()->shop->product_upload_limit }} {{ translate('Times') }}
                            </p>
                        </div>
                    </div>
                    <p class="jzriqi">
                             <img src="{{ static_asset('assets/img/newimg/home/time.png') }}" alt="" width="">

                      {{ translate('Package Expires at') }}:
                                {{ Auth::user()->shop->package_invalid_at }}
                    </p>
                    <a class="shengji" href="{{ route('seller.seller_packages_list') }}">
                      {{ translate('Upgrade Package') }}
                    </a>
                </div>
           
                @else
                <h6 class="fw-600 mb-3 text-primary">{{ translate('Package Not Found') }}</h6>
                @endif

            </div>
        </div>
        @endif
       
    </div>
                
                <div class="quick pc">
                    <a href="{{ route('seller.money_withdraw_requests.index') }}">
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q1.png') }}" alt="" width="">

                        </p>
                        <h2>
                             {{ translate('Money Withdraw') }}
                        </h2>
                    </a>
                    <a href="{{ route('seller.product_storehouse.index') }}">
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q2.png') }}" alt="" width="">
                        </p>
                        <h2>
                          {{ translate('Product Storehouse') }}
                        </h2>
                    </a>
                    <a href="{{ route('seller.shop.index') }}">
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q3.png') }}" alt="" width="">
                        </p>
                        <h2>
                           {{ translate('Shop Settings') }}
                        </h2>
                    </a>
                    <a href="{{ route('seller.profile.index') }}" >
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q4.png') }}" alt="" width="">
                        </p>
                        <h2>
                            {{ translate('Payment Settings') }}
                        </h2>
                    </a>
                </div>
                <div class="chahua">
     <img src="{{ static_asset('assets/img/newimg/home/chahua.png') }}" alt="" width="">

                </div>
            </div>
            <div class="quick m" >
                     <a href="{{ route('seller.money_withdraw_requests.index') }}">
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q1.png') }}" alt="" width="">

                        </p>
                        <h2>
                             {{ translate('Money Withdraw') }}
                        </h2>
                    </a>
                        <a href="{{ route('seller.product_storehouse.index') }}">
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q2.png') }}" alt="" width="">
                        </p>
                        <h2>
                            {{ translate('Product Storehouse') }}
                        </h2>
                    </a>
                    <a href="{{ route('seller.shop.index') }}">
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q3.png') }}" alt="" width="">
                        </p>
                        <h2>
                           {{ translate('Shop Settings') }}
                        </h2>
                    </a>
                    <a href="{{ route('seller.profile.index') }}" >
                        <p>
     <img src="{{ static_asset('assets/img/newimg/home/q4.png') }}" alt="" width="">
                        </p>
                        <h2>
                            {{ translate('Payment Settings') }}
                        </h2>
                    </a>
            </div>

            <div class="indexconL2">
                <a style="background: #3D7FFF">
                    <div class="idataL">
                        <p>
                            {{ translate('Products') }}
                        </p>
                        <h2>
                           {{ \App\Models\Product::where('user_id', Auth::user()->id)->count() }}
                        </h2>
                    </div>
                    <div class="idataR">
     <img src="{{ static_asset('assets/img/newimg/home/p1.png') }}" alt="" width="">
                    </div>
                </a>
                <a style="background: #F9AC27" class="pc">
                    <div class="idataL">
                        <p>
                            {{ translate('Total Sales') }}
                        </p>
                        <h2>
                           @php
                                    $orderDetails = \App\Models\OrderDetail::where('seller_id', Auth::user()->id)->get();
                                    $total = 0;
                                    foreach ($orderDetails as $key => $orderDetail) {
                                        if ($orderDetail->order != null && $orderDetail->order->payment_status == 'paid') {
                                            $total += $orderDetail->price;
                                        }
                                    }
                                @endphp
                                {{ single_price($total) }}
                        </h2>
                    </div>
                    <div class="idataR">
     <img src="{{ static_asset('assets/img/newimg/home/p2.png') }}" alt="" width="">
                    </div>
                </a>
                <a style="background: #C97BF3">
                    <div class="idataL">
                        <p>
                            {{ translate('Total Order') }}
                        </p>
                        <h2>
                                                            {{ \App\Models\Order::where('seller_id', Auth::user()->id)->where('delivery_status', 'delivered')->count() }}

                        </h2>
                    </div>
                    <div class="idataR">
     <img src="{{ static_asset('assets/img/newimg/home/p3.png') }}" alt="" width="">
                    </div>
                </a>
                <a style="background: #F9AC27" class="m">
                    <div class="idataL">
                        <p>
                            Products
                        </p>
                        <h2>
                              {{ \App\Models\Product::where('user_id', Auth::user()->id)->count() }}
                        </h2>
                    </div>
                    <div class="idataR">
     <img src="{{ static_asset('assets/img/newimg/home/p2.png') }}" alt="" width="">
                    </div>
                </a>
            </div>
            <div class="indexconL3">
                <h3 class="indTit">
                    {{ translate('Orders') }}<span>（{{ translate('This Month') }}）</span>
                </h3>
                <div class="indexconL3con">
                    <a>
                        <div class="idata2L">
                            <p>
                                {{ translate('New Order') }}
                            </p>
                            <h2>
                                                                {{ \App\Models\OrderDetail::where('seller_id', Auth::user()->id)->where('delivery_status', 'pending')->count() }}

                            </h2>
                        </div>
                        <div class="idata2R">
     <img src="{{ static_asset('assets/img/newimg/home/o1.png') }}" alt="" width="">
                        </div>
                    </a>
                    <a>
                        <div class="idata2L">
                            <p>
                                {{ translate('Cancelled') }}
                            </p>
                            <h2>
                                                                {{ \App\Models\OrderDetail::where('seller_id', Auth::user()->id)->where('delivery_status', 'cancelled')->count() }}

                            </h2>
                        </div>
                        <div class="idata2R">
     <img src="{{ static_asset('assets/img/newimg/home/o2.png') }}" alt="" width="">
                        </div>
                    </a>
                    <a>
                        <div class="idata2L">
                            <p>
                                {{ translate('On Delivery') }}
                            </p>
                            <h2>
                                                                {{ \App\Models\OrderDetail::where('seller_id', Auth::user()->id)->where('delivery_status', 'on_the_way')->count() }}

                            </h2>
                        </div>
                        <div class="idata2R">
     <img src="{{ static_asset('assets/img/newimg/home/o3.png') }}" alt="" width="">
                        </div>
                    </a>
                    <a>
                        <div class="idata2L">
                            <p>
                                {{ translate('Delivered') }}
                            </p>
                            <h2>
                                                                {{ \App\Models\OrderDetail::where('seller_id', Auth::user()->id)->where('delivery_status', 'delivered')->count() }}

                            </h2>
                        </div>
                        <div class="idata2R">
     <img src="{{ static_asset('assets/img/newimg/home/o4.png') }}" alt="" width="">
                        </div>
                    </a>
                </div>
            </div>
        </div>
        <div class="indexconR">
            <div class="indexconR1">
                   @php
                    $date = date('Y-m-d');
                    $days_ago_30 = date('Y-m-d', strtotime('-30 days', strtotime($date)));
                    $days_ago_60 = date('Y-m-d', strtotime('-60 days', strtotime($date)));

                    $orderTotal = \App\Models\Order::where('seller_id', Auth::user()->id)
                        ->where('payment_status', 'paid')
                        ->where('created_at', '>=', $days_ago_30)
                        ->sum('grand_total');
                @endphp
                <h3 class="indTit">
                   {{ translate('Sold Amount') }}
                
                </h3>
                <h2>
                  {{ translate('Your Sold Amount (Current month)') }}
                </h2>
                <h4>
                  {{ single_price($orderTotal) }}
                </h4>
                <p>
                     @php
                            $orderTotal = \App\Models\Order::where('seller_id', Auth::user()->id)
                                ->where('payment_status', 'paid')
                                ->where('created_at', '>=', $days_ago_60)
                                ->where('created_at', '<=', $days_ago_30)
                                ->sum('grand_total');
                        @endphp
                         
                   {{ translate('Last Month') }}: <span>{{ single_price($orderTotal) }}</span>
                         <img src="{{ static_asset('assets/img/newimg/home/qushi.png') }}" alt="" width="">

                </p>
                <h3 class="indTit">
                   {{ translate('Shop View Count') }}
                </h3>
                <p> <span>{{Auth::user()->shop->views}}</span>
                 <img src="{{ static_asset('assets/img/newimg/home/qushi.png') }}" alt="" width="">
                </p>
                
                
            </div>

            <div class="indexconR2">
                <h3 class="indTit">
                   {{ translate('Top 12 Products') }}
                </h3>
                   <div class="card-body">
          
            <div class="aiz-carousel gutters-10 half-outside-arrow" data-items="8" data-xl-items="8" data-lg-items="4"
                data-md-items="3" data-sm-items="4" data-arrows='true' data-vertical='true'>
                @foreach ($products as $key => $product)
                    <div class="carousel-box">
                        <div
                            class="aiz-card-box " style="display:flex;">
                            <div class="position-relative">
                                <a href="{{ route('product', $product->slug) }}" class="d-block">
                                    <img class="img-fit lazyload mx-auto h-96px" style="width:96px;height:96px"
                                        src="{{ static_asset('assets/img/placeholder.jpg') }}"
                                        data-src="{{ uploaded_asset($product->thumbnail_img) }}"
                                        alt="{{ $product->getTranslation('name') }}"
                                        onerror="this.onerror=null;this.src='{{ static_asset('assets/img/placeholder.jpg') }}';">
                                </a>
                            </div>
                            <div class="p-md-3 p-2 text-left">
                              
                                  <h3 class="fw-600 fs-13 text-truncate-2 lh-1-4 mb-0">
                                    <a href="{{ route('product', $product->slug) }}"
                                        class="d-block text-reset">{{ $product->getTranslation('name') }}</a>
                                </h3>
                                <div class="rating rating-sm mt-1">
                                    {{ renderStarRating($product->rating) }}
                                </div>
                                  <div class="fs-15">
                                    @if (home_base_price($product) != home_discounted_base_price($product))
                                        <del class="fw-600 opacity-50 mr-1">{{ home_base_price($product) }}</del>
                                    @endif
                                    <span class="fw-700 text-primary">{{ home_discounted_base_price($product) }}</span>
                                </div>
                              
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>
        </div>
        
                <div class="carousel-box" style="display:none">
                                    <ul class="top12">
                      @foreach ($products as $key => $product)
                    <li>
                       <a href="{{ route('product', $product->slug) }}" class="d-block">
                                    <img class="img-fit lazyload mx-auto h-210px"
                                        src="{{ static_asset('assets/img/placeholder.jpg') }}"
                                        data-src="{{ uploaded_asset($product->thumbnail_img) }}"
                                        alt="{{ $product->getTranslation('name') }}"
                                        onerror="this.onerror=null;this.src='{{ static_asset('assets/img/placeholder.jpg') }}';">
                                </a>
                                
                        <div class="top12R">
                            <h2>
 <a href="{{ route('product', $product->slug) }}"
                                        class="d-block text-reset">{{ $product->getTranslation('name') }}</a>                            </h2>
                            <div class="pinfen">
 <div class="rating rating-sm mt-1">
                                    {{ renderStarRating($product->rating) }}
                                </div>
                            </div>
                            <div class="price">
                                @if (home_base_price($product) != home_discounted_base_price($product))
                                        <del class="fw-600 opacity-50 mr-1">{{ home_base_price($product) }}</del>
                                    @endif
                                    <span class="fw-700 text-primary">{{ home_discounted_base_price($product) }}</span>
                                    
                            </div>
                        </div>
                    </li>
                     @endforeach
                </ul>

                </div>
            </div>
        </div>
    </div>

    <!--旧的-->

  
@endsection

@section('script')
    <script type="text/javascript">
        AIZ.plugins.chart('#graph-1', {
            type: 'bar',
            data: {
                labels: [
                    @foreach ($last_7_days_sales as $key => $last_7_days_sale)
                        '{{ $key }}',
                    @endforeach
                ],
                datasets: [{
                    label: 'Sales ($)',
                    data: [
                        @foreach ($last_7_days_sales as $key => $last_7_days_sale)
                            '{{ $last_7_days_sale }}',
                        @endforeach
                    ],

                    backgroundColor: ['#0277BD', '#0277BD', '#0277BD', '#0277BD', '#0277BD', '#0277BD',
                        '#0277BD'
                    ],
                    borderColor: ['#0277BD', '#0277BD', '#0277BD', '#0277BD', '#0277BD', '#0277BD',
                        '#0277BD'
                    ],
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    yAxes: [{
                        gridLines: {
                            color: '#D2E7F2',
                            zeroLineColor: '#f2f3f8'
                        },
                        ticks: {
                            fontColor: "#84A8BD",
                            fontFamily: 'Roboto',
                            fontSize: 10,
                            beginAtZero: true
                        },
                    }],
                    xAxes: [{
                        gridLines: {
                            display: false
                        },
                        ticks: {
                            fontColor: "#8b8b8b",
                            fontFamily: 'Roboto',
                            fontSize: 10
                        },
                        barThickness: 7,
                        barPercentage: .5,
                        categoryPercentage: .5,
                    }],
                },
                legend: {
                    display: false
                }
            }
        });
    </script>
@endsection
